<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>后台主界面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/admin.css' type="text/css" />
<script src="<?php echo $static_url; ?>common/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="<?php echo $static_url; ?>common/js/common.js" type="text/javascript"></script>
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/user_list.css' type="text/css" />
</head>
<body class="body_background">
	<div>
		<?php echo $header_nav; ?>
		<div style="margin-top:15px;">
		<div class="crumbs">
			<span class="catalogue">权限管理</span>
			<a href="/www/admin/role/position_lists.php">职务管理</a> | <a href="/www/admin/role/user_lists.php">人员管理</a>
		</div>
		<div class="user_list_main">
			<table class="record_tips"><tr><td class="colorstyle">人员管理列表</td></tr></table>
			<table class="userlist_table">
				<thead>
					<tr>
						<th>用户ID</th>
						<th>用户名</th>
						<th>职务</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<?php foreach($users_rs as $user): ?>
					<tr>
						<td><?php echo $user['uid']; ?></td>
						<td><?php echo $user['username']; ?></td>
						<td><?php echo $user['name']; ?></td>
						<td><?php echo ($user['locked']==1)?'使用中':'<font style="color:red;">已锁定</font>'; ?></td>
						<td>
							<?php if($user['id'] != 1): ?>
							<a href="/www/admin/role/edit_user.php?id=<?php echo $user['id']; ?>">编辑</a> |
							<a href="javascript:;" onclick="{if(confirm('确定删除成员 <?php echo $user['username']; ?> ？')){del(this,<?php echo $user['id']; ?>);}return false;}">删除</a>
							<?php endif; ?>
						</td>
					</tr>
					<?php endforeach; ?>
					<tr><td colspan="5">&nbsp;</td></tr>
					<form id="add_user_form" method="post" action="/www/admin/role/do/do_add_user.php">
					<tr>
						<td>&nbsp;</td>
						<td><input type="text" name="username" id="username"/></td>
						<td>
							<select name="groupid">
								<?php foreach($position_rs as $position): ?>
									<option value="<?php echo $position['id']; ?>"><?php echo $position['name']; ?></option>
								<?php endforeach; ?>
							</select>
						</td>
						<td>&nbsp;</td>
						<td>
							<a onclick="add()" href="javascript:;">添加</a>
						</td>
					</tr>
					</form>
				</tbody>
			</table>
		</div>
		</div>
	</div>
<script>
//删除
function del(e, i){<!-- i:id号 -->
	$.ajax({
		type: "POST",
		url: "/admin/role/ajax/ajax_del_user.php",
		dataType:'json',
		data: {"id":i},
		beforeSend: function(){
			$(e).html( '删除中' );
		},
		success: function(msg){
			alert(msg.string);
			$(e).html( '删除' );
			if(msg.error){
				window.location.href="/www/admin/role/user_lists.php";
			}
		}
	});
}

//添加
function add(){
	var username = $('#username');
	if( username.val() == '' ){
		username.focus();
		alert('请输入用户名');
	}else{
		document.getElementById('add_user_form').submit();
	}
}
</script>
</body>
</html>